<?php

require_once("./././public/fpdf17/fpdf.php");


class PDF_Rotate extends FPDF{
	var $angle=0;
	var $registry;
	public function __construct($registry) {
        parent::__construct($registry);
		
    }
	

	function Rotate($angle,$x=-1,$y=-1){
		if($x==-1)
			$x=$this->x;
		if($y==-1)
			$y=$this->y;
		if($this->angle!=0)
			$this->_out('Q');
		$this->angle=$angle;
		if($angle!=0)
		{
			$angle*=M_PI/180;
			$c=cos($angle);
			$s=sin($angle);
			$cx=$x*$this->k;
			$cy=($this->h-$y)*$this->k;
			$this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
		}
	}

	function _endpage(){
		if($this->angle!=0)
		{
			$this->angle=0;
			$this->_out('Q');
		}
		parent::_endpage();
	}

	function Header(){
		//Put the watermark
		$this->SetFont('Arial','B',80);
		$this->SetTextColor(224,224,224);
		 if ($this->options['orientation'] == "L") {
			//$this->RotatedText(300,300,'OMSPAN',0);
        } else {
			//$this->RotatedText(150,400,'OMSPAN',0);
        }
	}

	function RotatedText($x, $y, $txt, $angle)
	{
		//Text rotated around its origin
		$this->Rotate($angle,$x,$y);
		$this->Text($x,$y,$txt);
		$this->Rotate(0);
	}
	
	public function v_umum(){
		
		
	} 

	
	function HeaderAtas1($judul,$par_umum1){
		//-----------------------------------
/* 				//------------------------//kolas
		//------------------------//
			//parameter//
			
			if ($kdsatker != 'null') {
				$kodenm_satker=$kdsatker;
			}else{
				$kodenm_satker='null';
			}			
			if ($kdbulan != 'null') {
				$kdbulan=$kdbulan;
			}else{
				$kdbulan='null';
			}
			if ($kdtgl_awal != 'null' && $kdtgl_akhir != 'null') {
				
			} else {
				$kdtgl_awal = 'null';
				$kdtgl_akhir = 'null';
			}
			if ($kdbln_awal != 'null' && $kdbln_akhir != 'null') {
				
			} else {
				$kdbln_awal = 'null';
				$kdbln_akhir = 'null';
			}
			if ($v1 != 'null' && $v2 != 'null') {
				$v1=$v1;
				$v2=$v2;
			}else{
				$v1='null';
				$v2='null';
			}
			if ($v3 != 'null' && $v4 != 'null') {
				$v3=$v3;
				$v4=$v4;
			}else{
				$v3='null';
				$v4='null';
			}
			if ($v5 != 'null' && $v6 != 'null') {
				$v5=$v5;
				$v6=$v6;
			}else{
				$v5='null';
				$v6='null';
			}
			if ($v7 != 'null') {
				$v7=$v7;
			}else{
				$v7='null';
			}
			if ($v8 != 'null') {
				$v8=$v8;
			}else{
				$v8='null';
			}
			if ($v9 != 'null') {
				$v9=$v9;
			}else{
				$v9='null';
			}
			$par_umum1 = array('kdtgl_awal' => $kdtgl_awal,'kdtgl_akhir' => $kdtgl_akhir,
			'kodenm_satker' => $kodenm_satker,'kdbln_awal' => $kdbln_awal,'kdbln_akhir' => $kdbln_akhir,
			'kdbulan' => $kdbulan,'v1' => $v1,'v2' => $v2,'v3' => $v3,'v4' => $v4,'v5' => $v5,'v6' => $v6,'v7' => $v7,'v8' => $v8,'v9' => $v9);
			//------------------------//
 */
		
            
		if (Session::get('role') == ADMIN) {
			
			$nm_kppn = 'DITJEN PERBENDAHARAAN';
			
        }elseif (Session::get('role') == PKN) {
			$nm_kppn = Session::get('user');
        }elseif (Session::get('role') == BLU) {
			$nm_kppn = Session::get('user');
        }elseif (Session::get('role') == MENKEU) {			 
			$kdbaes1=Session::get('kd_satker');
			if ($kdbaes1 != 'null') {				
                 $d_kppn = new DataUser($this->registry);
                $d_kppn->get_d_user_kppn($kdbaes1);
                foreach ($d_kppn->get_d_user_kppn($kdbaes1) as $kppn) {
                    $nm_kppn = $kppn->get_nama_user();		
                }
            } else {
                $nm_kppn = 'null';
            }	
		}elseif (Session::get('role') == DJA) {
			$nm_kppn = Session::get('user');
        }elseif (Session::get('role') == KANWIL) {
			$nm_kppn = Session::get('user');
        }elseif (Session::get('role') == KPPN) {
			$nm_kppn = Session::get('user');
        }elseif (Session::get('role') == KL) {			 
			$kdbaes1=Session::get('kd_satker');
			if ($kdbaes1 != 'null') {				
                 $d_kppn = new DataUser($this->registry);
                $d_kppn->get_d_user_kppn($kdbaes1);
                foreach ($d_kppn->get_d_user_kppn($kdbaes1) as $kppn) {
                    $nm_kppn2 = $kppn->get_nama_user();		
                }
            } else {
                $nm_kppn2 = 'null';
            }	
		}elseif (Session::get('role') == ES1) {
			$kdbaes1=Session::get('kd_satker');
			if ($kdbaes1 != 'null') {
				//KL
                $d_kppn = new DataUser($this->registry);
                $d_kppn->get_d_user_kppn($kdbaes1);
                foreach ($d_kppn->get_d_user_kppn($kdbaes1) as $kppn) {
                    $nm_kppn2 = $kppn->get_nama_user();
                }
				//ES1
				$kppn1='KL'.substr($kdbaes1,1,3);
				$d_kppn1 = new DataUser($this->registry);
				$d_kppn1->get_d_user_kppn2($kppn1);
                foreach ($d_kppn1->get_d_user_kppn2($kppn1) as $kppn1) {
                    $nm_kppn3 = $kppn1->get_nama_user1();
                }
			}else {
                $nm_kppn2 = 'null';
				$nm_kppn3 = 'null';
            }
				
        } elseif (Session::get('role') == SATKER) {
				 $d_kppn = new DataUser($this->registry);
				$d_kppn->get_d_user_nmkppn(Session::get('kd_satker'));
				foreach ($d_kppn->get_d_user_nmkppn(Session::get('kd_satker')) as $kppn) {
					$nm_kppn = $kppn->get_nama_kppn();
				}
        } elseif (Session::get('role') == BANK) {
			$nm_kppn = Session::get('user');
        } else {
			$nm_kppn = Session::get('user');
        } 
 	//----------------------------------------------------------------

		$kemenkeu = 'Kementerian Keuangan Republik Indonesia';
		$left=20;
		$h1 = 35;
        $this->SetFont("", "B", 10);
        $this->SetX($left + 20);
        $this->Image("./././public/img/depkeu.png", 30, 30, 30, 30);
        $px1 = $this->GetX();
        $this->SetX($left + 50);
        $this->MultiCell(0, $h1 / 2, strtoupper($kemenkeu));
        $py1 = $this->GetY();
        $px2 = $px1;
        $py2 = $py1;
        $this->SetXY($px2, $py2);
        $this->SetX($left + 50);
 
        if (Session::get('role') == ADMIN
		|| Session::get('role') == PKN
		|| Session::get('role') == BLU		
		|| Session::get('role') == DJA  
		|| Session::get('role') == KANWIL
		|| Session::get('role') == KPPN
		|| Session::get('role') == SATKER
		|| Session::get('role') == BANK
		){
					
			if (substr(trim($nm_kppn), 0, 3) == 'SET') {  //ADMIN
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 5) == 'ADMIN') { //ADMIN
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 3) == 'DIT') {  //PKN,APK,DSP
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 5) == 'BADAN') { //BLU
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			} elseif (substr(trim($nm_kppn), 0, 5) == 'Direktorat') { //DJA
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 6) == 'KANWIL') { //KANWIL
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 4) == 'KPPN') { //KPPN
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 5) == 'null') { //SATKER
				$this->MultiCell(0, $h1 / 2, '');
			}elseif (substr(trim($nm_kppn), 0, 4) == 'BANK') { //BANK
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 5) == '') { //6
				$this->MultiCell(0, $h1 / 2, '');
			} else {
				$this->MultiCell(0, $h1 / 2, 'KPPN ' . $nm_kppn);
			}
			
			
		}elseif(
		Session::get('role') == KL 
		|| Session::get('role') == ES1
		|| Session::get('role') == MENKEU
		){
			
			if (substr(trim($nm_kppn), 0, 7) == 'MENTERI') { //6
				$this->MultiCell(0, $h1 / 2, $nm_kppn);
			}elseif (substr(trim($nm_kppn), 0, 5) == 'null') { //6
				$this->MultiCell(0, $h1 / 2, '');
			}elseif (substr(trim($nm_kppn), 0, 5) == '') { //6
				$this->MultiCell(0, $h1 / 2, 'DITJEN PERBENDAHARAAN');
			} else {
				$this->MultiCell(0, $h1 / 2, 'KPPN ' . $nm_kppn);
			}
		}
 
        $this->Cell(0, 1, " ", "B");
        $this->Ln(20);
        $this->Cell(0,0, strtoupper($judul), 0, 0, 'C', false);
        $this->Ln(5);
        //tanggal
		$kdtgl_awal=$par_umum1['kdtgl_awal'];
		$kdtgl_akhir=$par_umum1['kdtgl_akhir'];
		//var_dump($kdtgl_awal);
		//var_dump($kdtgl_akhir);
		//bulan
		$kdbln_awal=$par_umum1['kdbln_awal'];
		$kdbln_akhir=$par_umum1['kdbln_akhir'];
		//var_dump($kdbln_awal);
		//var_dump($kdbln_akhir);
		if(isset($kdtgl_awal) || isset($kdtgl_akhir) || isset($kdbln_awal) || isset($kdbln_akhir)){
			if(isset($kdbln_awal) && isset($kdbln_akhir)){
				if ($kdbln_awal != 'null' && $kdbln_akhir != 'null'){
					
					if($kdbln_awal=='01'){
						$kdbln_awal1='JANUARI';
					}elseif($kdbln_awal=='02'){
						$kdbln_awal1='FEBRUARI';
					}elseif($kdbln_awal=='03'){
						$kdbln_awal1='MARET';
					}elseif($kdbln_awal=='04'){
						$kdbln_awal1='APRIL';
					}elseif($kdbln_awal=='05'){
						$kdbln_awal1='MEI';
					}elseif($kdbln_awal=='06'){
						$kdbln_awal1='JUNI';
					}elseif($kdbln_awal=='07'){
						$kdbln_awal1='JULI';
					}elseif($kdbln_awal=='08'){
						$kdbln_awal1='AGUSTUS';
					}elseif($kdbln_awal=='09'){
						$kdbln_awal1='SEPTEMBER';
					}elseif($kdbln_awal=='10'){
						$kdbln_awal1='OKTOBER';
					}elseif($kdbln_awal=='11'){
						$kdbln_awal1='NOVEMBER';
					}elseif($kdbln_awal=='12'){
						$kdbln_awal1='DESEMBER';
					}else{
						
					}
					
					if($kdbln_akhir=='01'){
						$kdbln_akhir1='JANUARI';
					}elseif($kdbln_akhir=='02'){
						$kdbln_akhir1='FEBRUARI';
					}elseif($kdbln_akhir=='03'){
						$kdbln_akhir1='MARET';
					}elseif($kdbln_akhir=='04'){
						$kdbln_akhir1='APRIL';
					}elseif($kdbln_akhir=='05'){
						$kdbln_akhir1='MEI';
					}elseif($kdbln_akhir=='06'){
						$kdbln_akhir1='JUNI';
					}elseif($kdbln_akhir=='07'){
						$kdbln_akhir1='JULI';
					}elseif($kdbln_akhir=='08'){
						$kdbln_akhir1='AGUSTUS';
					}elseif($kdbln_akhir=='09'){
						$kdbln_akhir1='SEPTEMBER';
					}elseif($kdbln_akhir=='10'){
						$kdbln_akhir1='OKTOBER';
					}elseif($kdbln_akhir=='11'){
						$kdbln_akhir1='NOVEMBER';
					}elseif($kdbln_akhir=='12'){
						$kdbln_akhir1='DESEMBER';
					}else{
						
					}
					$this->Cell(0, 20, 'PERIODE: ' . $kdbln_awal1 . ' s/d ' . $kdbln_akhir1 .' '. Session::get('ta'), 0, 0, 'C', false);
					
				}elseif ($kdbln_awal == 'null' && $kdbln_akhir == 'null') {
					$kdbln_akhir1=date('m') ;
						if($kdbln_akhir1=='01'){
							$kdbln_akhir1='JANUARI';
						}elseif($kdbln_akhir1=='02'){
							$kdbln_akhir1='FEBRUARI';
						}elseif($kdbln_akhir1=='03'){
							$kdbln_akhir1='MARET';
						}elseif($kdbln_akhir1=='04'){
							$kdbln_akhir1='APRIL';
						}elseif($kdbln_akhir1=='05'){
							$kdbln_akhir1='MEI';
						}elseif($kdbln_akhir1=='06'){
							$kdbln_akhir1='JUNI';
						}elseif($kdbln_akhir1=='07'){
							$kdbln_akhir1='JULI';
						}elseif($kdbln_akhir1=='08'){
							$kdbln_akhir1='AGUSTUS';
						}elseif($kdbln_akhir1=='09'){
							$kdbln_akhir1='SEPTEMBER';
						}elseif($kdbln_akhir1=='10'){
							$kdbln_akhir1='OKTOBER';
						}elseif($kdbln_akhir1=='11'){
							$kdbln_akhir1='NOVEMBER';
						}elseif($kdbln_akhir1=='12'){
							$kdbln_akhir1='DESEMBER';
						}
						$this->Cell(0, 20, 'BULAN: s/d ' .$kdbln_akhir1.' '. Session::get('ta'), 0, 0, 'C', false);					
				}
			}
			$this->Ln(15);
			if(isset($kdtgl_awal) && isset($kdtgl_akhir)){
				
				if($kdtgl_awal != 'null' && $kdtgl_akhir != 'null') {
					//var_dump($kdtgl_awal);
					//var_dump($kdtgl_akhir);
					$thn1 = substr($kdtgl_awal, 6, 4);
					$bln1 = substr($kdtgl_awal, 3, 2);
					$tgl1 = substr($kdtgl_awal, 0, 2);
					$kdtgl_awal = $tgl1 . '-' . $bln1 . '-' . $thn1;
					$thn2 = substr($kdtgl_akhir, 6, 4);
					$bln2 = substr($kdtgl_akhir, 3, 2);
					$tgl2 = substr($kdtgl_akhir, 0, 2);
					$kdtgl_akhir = $tgl2 . '-' . $bln2 . '-' . $thn2;
					$this->Cell(0, 20, 'DARI TANGGAL: ' . $kdtgl_awal . ' s/d ' . $kdtgl_akhir, 0, 0, 'C', false);		

				}elseif ($kdtgl_awal = 'null' && $kdtgl_akhir = 'null') {
						$this->Cell(0, 20, 'TANGGAL : s/d ' .date('d-m-Y'), 0, 0, 'C', false);					
				}
			}			
		}else{
			//$this->Cell(0, 20, 'TANGGAL : s/d' .date('d-m-Y'), 0, 0, 'C', false);
		}
 	
		//--------------------

        //$this->Ln(20);
		$this->Ln(15);
         //----------------------------------------------- 
        $this->SetFont('Arial', 'B', 8);

        #pengaturan umum
		if (Session::get('role') == ADMIN  || Session::get('role') == DJA  || Session::get('role') == KANWIL){
			
		}elseif(Session::get('role') == KL){
			$this->Cell(0,0,'KEMENTERIAN/LEMBAGA   : '.trim($nm_kppn2), 0, 0, 'L', false);
			$this->Ln(12);
		}elseif(Session::get('role') == ES1){
			$this->Cell(0,0,'KEMENTERIAN/LEMBAGA   : '.trim($nm_kppn3), 0, 0, 'L', false);
			$this->Ln(12);
			$this->Cell(0,0,'ESELON I : '.trim($nm_kppn2), 0, 0, 'L', false);
			$this->Ln(12);
		}
		//nama satker
		$kodenm_satker=$par_umum1['kodenm_satker'];
		if(isset($kodenm_satker)){
			//var_dump($kodenm_satker);
		if($kodenm_satker != 'null'){
			$d_kppn = new DataUser($this->registry);
			foreach ($d_kppn->get_d_user_kppn($kodenm_satker) as $nm_satker1) {
					$nm_satker = $nm_satker1->get_nama_user();
			} 
				
			if(strlen($kodenm_satker)==3){
				$kodenm_satker1=trim($nm_satker).' - '.trim($kodenm_satker);
				$this->Cell(0,0,$kodenm_satker1, 0, 0, 'L', false);
			}elseif(strlen($kodenm_satker)==6){
				$kodenm_satker1=trim($nm_satker).' - '.trim($kodenm_satker);
				$this->Cell(0,0,'SATKER  : '.$kodenm_satker1, 0, 0, 'L', false);
			}
					
			
		}
			
		}
		  

		$this->Ln(20);	

			
		//------------------------------------------------------------------
		$this->SetFillColor(127,170,241);
		
	}
	 //footer
    function Footer() {
		
        // Go to 1.5 cm from bottom
        $this->SetY(-15);
        // Select Arial italic 8
        $this->SetFont('Arial', 'I', 8);
        // Print centered page number
        $this->Cell(0, 10, 'Hal : ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
        $hari_ini =  Date("Y-m-d H:i:s");
        $this->Cell(0, 10, 'Dicetak : ' . $hari_ini, 0, 0, 'R');
		
    }
	  
	
    private $widths;
    private $aligns;

    function SetWidths($w) {
        //Set the array of column widths
        $this->widths = $w;
    }

    function SetAligns($a) {
        //Set the array of column alignments
        $this->aligns = $a;
    }
	function Row($data) {
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for ($i = 0; $i < count($data); $i++) {
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            //Draw the border
            $this->Rect($x, $y, $w, $h);
            //Print the text
            $this->MultiCell($w, 10, $data[$i], 0, $a);
            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }
	
	function Row1($data1) {
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data1); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data1[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for ($i = 0; $i < count($data1); $i++) {
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            //Draw the border
            $this->Rect($x, $y, $w, $h);
            //Print the text
            $this->MultiCell($w, 10, $data1[$i], 0, $a);
            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }
    
	
	function Row2($data2) {
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data2); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data2[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for ($i = 0; $i < count($data2); $i++) {
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            //Draw the border
            $this->Rect($x, $y, $w, $h);
            //Print the text
            $this->MultiCell($w, 10, $data2[$i], 0, $a);
            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }
	function Row3($data3) {
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data3); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data3[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for ($i = 0; $i < count($data3); $i++) {
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            //Draw the border
            $this->Rect($x, $y, $w, $h);
            //Print the text
            $this->MultiCell($w, 10, $data3[$i], 0, $a);
            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }
	
	function Row4($data4) {
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data4); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data4[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for ($i = 0; $i < count($data4); $i++) {
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            //Draw the border
            $this->Rect($x, $y, $w, $h);
            //Print the text
            $this->MultiCell($w, 10, $data4[$i], 0, $a);
            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }

		function Row6($data6) {
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data6); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data6[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for ($i = 0; $i < count($data6); $i++) {
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            //Draw the border
            $this->Rect($x, $y, $w, $h);
            //Print the text
            $this->MultiCell($w, 10, $data6[$i], 0, $a);
            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }
	function Row7($data,$warna) {
		//echo 'tes';
        //Calculate the height of the row
        $nb = 0;
        for ($i = 0; $i < count($data); $i++)
            $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
        $h = 10 * $nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
		
        //Draw the cells of the row
        for ($i = 0; $i < count($data); $i++) {
			$warnasel=$warna[$i];
            $w = $this->widths[$i];
            $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x = $this->GetX();
            $y = $this->GetY();
            
            //Print the text
			
			$this->SetFillColor($warnasel[0],$warnasel[1],$warnasel[2]);
            $this->MultiCell($w, 10, $data[$i], 0, $a,true);
			$this->SetFillColor($warnasel[0],$warnasel[1],$warnasel[2]);
			//Draw the border
            $this->Rect($x, $y, $w, $h);

            //Put the position to the right of the cell
            $this->SetXY($x + $w, $y);
        }
        //Go to the next line
        $this->Ln($h);
    }

    function CheckPageBreak($h) {
        //If the height h would cause an overflow, add a new page immediately
        if ($this->GetY() + $h > $this->PageBreakTrigger)
            $this->AddPage($this->CurOrientation);
		$this->SetFillColor(127,170,241);
    }

    function NbLines($w, $txt) {
        //Computes the number of lines a MultiCell of width w will take
        $cw = &$this->CurrentFont['cw'];
        if ($w == 0)
            $w = $this->w - $this->rMargin - $this->x;
        $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
        $s = str_replace("\r", '', $txt);
        $nb = strlen($s);
        if ($nb > 0 and $s[$nb - 1] == "\n")
            $nb--;
        $sep = -1;
        $i = 0;
        $j = 0;
        $l = 0;
        $nl = 1;
        while ($i < $nb) {
            $c = $s[$i];
            if ($c == "\n") {
                $i++;
                $sep = -1;
                $j = $i;
                $l = 0;
                $nl++;
                continue;
            }
            if ($c == ' ')
                $sep = $i;
            $l+=$cw[$c];
            if ($l > $wmax) {
                if ($sep == -1) {
                    if ($i == $j)
                        $i++;
                } else
                    $i = $sep + 1;
                $sep = -1;
                $j = $i;
                $l = 0;
                $nl++;
            } else
                $i++;
        }
        return $nl;
    }
	
	
	
	
}
//pengaturan
$tipefile = '.pdf';
//'destinationfile' => 'D', //I=inline browser (default), F=local file, D=download
$destinationfile='D';

?>
